Page({
  data: {
    theme: '',
    ysxyzt: true,
    ysxyxs: true,
    xrjtb: false,
    sytpsp: false,
    sytpspa: false,
    sytpspb: false,
    sytpspc: false,
    sytpspd: false,
    sytpspe: false,
    bctpsp: false,
    bctpspa: false,
    bctpspb: false,
    bctpspc: false,
    bctpspd: false
  },
  onShow() {
    var that = this
    that.setData({
      theme: wx.getAppBaseInfo().theme,
      ysxyzt: true,
      ysxyxs: true,
      xrjtb: false,
      sytpsp: false,
      sytpspa: false,
      sytpspb: false,
      sytpspc: false,
      sytpspd: false,
      sytpspe: false,
      bctpsp: false,
      bctpspa: false,
      bctpspb: false,
      bctpspc: false,
      bctpspd: false
    })
    wx.getSetting({
      success(res) {
        let zt = res.authSetting['scope.writePhotosAlbum']
        if (zt == true) {
          that.setData({
            bctpsp: true
          })
        }
      }
    })
    if (wx.getStorageSync('qxsetting').lx == 'qx') {
      wx.getStorage({
        key: 'qxsetting',
        success(res) {
          var t = res.data
          that.setData({
            xrjtb: t.xrjtb,
            sytpsp: t.sytpsp,
            sytpspa: t.sytpspa,
            sytpspb: t.sytpspb,
            sytpspc: t.sytpspc,
            sytpspd: t.sytpspd,
            sytpspe: t.sytpspe,
            bctpspa: t.bctpspa,
            bctpspb: t.bctpspb,
            bctpspc: t.bctpspc,
            bctpspd: t.bctpspd
          })
          that.ysxyjc()
        }
      })
      return
    }
    that.ysxyjc()
  },
  ysxyjc() {
    var that = this
    wx.getPrivacySetting({
      success(res) {
        if (res.needAuthorization == true) {
          that.setData({
            sytpsp: false,
            bctpsp: false
          })
        }
        if (res.needAuthorization == false) {
          that.setData({
            ysxyzt: false
          })
        }
      }
    })
  },
  complete() {
    this.setData({
      ysxyxs: false
    })
  },
  onUnload() {
    var t = this.data
    wx.setStorage({
      key: 'qxsetting',
      data: {
        lx: 'qx',
        xrjtb: t.xrjtb,
        sytpsp: t.sytpsp,
        sytpspa: t.sytpspa,
        sytpspb: t.sytpspb,
        sytpspc: t.sytpspc,
        sytpspd: t.sytpspd,
        sytpspe: t.sytpspe,
        bctpspa: t.bctpspa,
        bctpspb: t.bctpspb,
        bctpspc: t.bctpspc,
        bctpspd: t.bctpspd
      }
    })
  },
  ysbhzy() {
    var app = getApp()
    if (app.globalData.network == 'none') {
      wx.showToast({
        title: '无网络',
        icon: 'error'
      })
      return
    }
    wx.openPrivacyContract()
  },
  tz() {
    var app = getApp()
    if (app.globalData.network == 'none') {
      wx.showToast({
        title: '无网络',
        icon: 'error'
      })
      return
    }
    wx.openSetting({
      fail() {
        wx.showToast({
          title: '暂不支持',
          icon: 'error'
        })
      }
    })
  },
  xrjtb(e) {
    var a = e.detail.value
    this.setData({
      xrjtb: a
    })
  },
  sytpsp(e) {
    var a = e.detail.value
    this.setData({
      sytpsp: a
    })
  },
  sytpspa(e) {
    var a = e.detail.value
    this.setData({
      sytpspa: a
    })
  },
  sytpspb(e) {
    var a = e.detail.value
    this.setData({
      sytpspb: a
    })
  },
  sytpspc(e) {
    var a = e.detail.value
    this.setData({
      sytpspc: a
    })
  },
  sytpspd(e) {
    var a = e.detail.value
    this.setData({
      sytpspd: a
    })
  },
  sytpspe(e) {
    var a = e.detail.value
    this.setData({
      sytpspe: a
    })
  },
  bctpspa(e) {
    var a = e.detail.value
    this.setData({
      bctpspa: a
    })
  },
  bctpspb(e) {
    var a = e.detail.value
    this.setData({
      bctpspb: a
    })
  },
  bctpspc(e) {
    var a = e.detail.value
    this.setData({
      bctpspc: a
    })
  },
  bctpspd(e) {
    var a = e.detail.value
    this.setData({
      bctpspd: a
    })
  }
})